package org.jeecg.modules.bigscreen.controller;


//import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.CommonAPI;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.bigscreen.entity.*;
import org.jeecg.modules.bigscreen.service.WaterJmReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @Description: 水控统计相关接口
 * @Author: sn
 * @Date:   2024-05-18
 * @Version: V1.0
 */
@Api(tags="数据大屏接口")
@RestController
@RequestMapping("/waterjmreport")
@Slf4j
public class WaterJmReportController {

	@Autowired
	private WaterJmReportService waterjmreportService;
	@Autowired
	private CommonAPI commonAPI;

	/**
	 * nb表统计
	 * */
	//#0089FE（蓝） #F5C6F5(粉) #F8E51A（黄）
	@AutoLog(value = "积木报表水具api-nb表统计(环图)")
	@ApiOperation(value="积木报表水具api-nb表统计", notes="积木报表水具api-nb表统计")
	@GetMapping(value = "/queryNBWaterData")
	public String  queryNBWaterData() {
		JsonArray queryNBDate = waterjmreportService.queryNBChart();
		JSONObject object = new JSONObject();
		object.put("data",queryNBDate);
		Gson gson = new Gson();
		String jsonOutput = gson.toJson(object);

		return jsonOutput;
	}
	/**
	 * lora表统计
	 * */
	//#0089FE（蓝） #F5C6F5(粉) #F8E51A（黄）
	@AutoLog(value = "积木报表水具api-lora表统计(环图)")
	@ApiOperation(value="积木报表水具api-lora表统计", notes="积木报表水具api-lora表统计")
	@GetMapping(value = "/queryLoraWaterData")
	public String  queryLoraWaterData() {
		JsonArray queryLoraDate = waterjmreportService.queryLoraChart();
		JSONObject object = new JSONObject();
		object.put("data",queryLoraDate);
		Gson gson = new Gson();
		String jsonOutput = gson.toJson(object);
		return jsonOutput;
	}

	@AutoLog(value = "积木报表水具api-按校区统计表格")
	@ApiOperation(value="积木报表水具api-按校区统计表格", notes="积木报表水具api-按校区统计表格")
	@GetMapping(value = "/queryCampusWaterData")
	public JSONObject  queryCampusWaterData() {
		List<Map<String,String>>  queryLoraDate = waterjmreportService.queryCampusWaterData();
		JSONObject object = new JSONObject();
		object.put("data",queryLoraDate);
		object.put("total",(int)Math.ceil(queryLoraDate.size() / (double)20000));
		object.put("count",queryLoraDate.size());
		return object;
	}
	@AutoLog(value = "积木报表水具api-按楼宇统计表格")
	@ApiOperation(value="积木报表水具api-按楼宇统计表格", notes="积木报表水具api-按楼宇统计表格")
	@GetMapping(value = "/queryBuildingWaterData")
	public JSONObject  queryBuildingWaterData() {
		List<Map<String,String>>  queryLoraDate = waterjmreportService.queryBuildingWaterData();
		JSONObject object = new JSONObject();
		object.put("data",queryLoraDate);
		object.put("total",(int)Math.ceil(queryLoraDate.size() / (double)20000));
		object.put("count",queryLoraDate.size());
		return object;
	}


	@AutoLog(value = "积木报表水具api-按楼宇水表柱形图")
	@ApiOperation(value="积木报表水具api-按楼宇水表柱形图", notes="积木报表水具api-按楼宇水表柱形图")
	@GetMapping(value = "/queryBuildingWaterChart")
	//#0089FE（蓝） #F5C6F5(粉) #F8E51A（黄）
	public String  queryBuildingWaterChart() {
		JsonArray jmreportHotelDate = waterjmreportService.queryBuildingWaterChart();
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		Gson gson = new Gson();
		String jsonOutput = gson.toJson(object);
		return  jsonOutput;
	}



	@AutoLog(value = "积木报表日用水量api-按楼宇统计表格")
	@ApiOperation(value="积木报表日用水量api-按楼宇统计表格", notes="积木报表日用水量api-按楼宇统计表格")
	@GetMapping(value = "/queryBuildingUseWaterData")
	public JSONObject  queryBuildingUseWaterData() throws ParseException {
		List<WaterJmReportDailyDate>  queryLoraDate = waterjmreportService.queryBuildingUseWaterData();
		JSONObject object = new JSONObject();
		object.put("data",queryLoraDate);
		object.put("total",(int)Math.ceil(queryLoraDate.size() / (double)20000));
		object.put("count",queryLoraDate.size());
		return object;
	}

	@AutoLog(value = "积木报表日用水量api-按楼宇水量柱状图")
	@ApiOperation(value="积木报表日用水量api-按楼宇水量柱状图", notes="积木报表日用水量api-按楼宇水量柱状图")
	@GetMapping(value = "/queryBuildingUseWaterChart")

	public String  queryBuildingUseWaterChart() throws ParseException {
		JsonArray jmreportHotelDate = waterjmreportService.queryBuildingDailyWaterChart();
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		Gson gson = new Gson();
		String jsonOutput = gson.toJson(object);
		return  jsonOutput;
	}



	/**
	 * 获取楼宇住宿数据---钻取1
	 *
	 * @return
	 */
/*	@AutoLog(value = "积木报表api-房间住宿情况")
	@ApiOperation(value="积木报表api-房间住宿情况", notes="积木报表api-房间住宿情况")
	@GetMapping(value = "/queryLhHotelData")
	public JSONObject  queryLhHotelData(
			@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,
			@RequestParam(name = "pageSize",defaultValue = "1") Integer pageSize,
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName

	) {

		List<JmReportHotelDate> jmreportHotelDate = jmreportService.getLhHotelData(pageNo,pageSize,campusName, buildingName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		object.put("total",(int)Math.ceil(jmreportHotelDate.size() / (double)pageSize));
		object.put("count",jmreportHotelDate.size());
		return object;
	}
	*//**
	 * 获取楼层住宿数据--钻取2
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-住宿统计")
	@ApiOperation(value="积木报表api-住宿统计", notes="积木报表api-住宿统计")
	@GetMapping(value = "/queryHotelData")
	public JSONObject  queryHotelData(
			@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,
			@RequestParam(name = "pageSize",defaultValue = "1") Integer pageSize,
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName

	) {

		List<JmReportHotelDate> jmreportHotelDate = jmreportService.getHotelData(pageNo,pageSize,campusName, buildingName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		object.put("total",(int)Math.ceil(jmreportHotelDate.size() / (double)pageSize));
		object.put("count",jmreportHotelDate.size());
		return object;
		*//*Page<JmReportHotelDate> page = new Page<JmReportHotelDate>(pageNo, pageSize);
		JSONObject object = new JSONObject();
			List<JmReportHotelDate> jmreportHotelDate = jmreportService.getHotelData(page,campusname,buildingname);

			object.put("data",jmreportHotelDate);
			object.put("total",(int)Math.ceil(jmreportHotelDate.size() / (double)pageSize));
			object.put("count",jmreportHotelDate.size());
			return object;*//*
	}


	*//**
	 * 获取毕业生数据
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-毕业生分布")
	@ApiOperation(value="积木报表api-毕业生分布", notes="积木报表api-毕业生分布")
	@GetMapping(value = "/queryGraduateData")
	public JSONObject  queryGraduateData(
			@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,
			@RequestParam(name = "pageSize",defaultValue = "20000") Integer pageSize,
			@RequestParam(value = "campusname",required = false)String campusname,
			@RequestParam(value = "buildingname",required = false)String buildingname

	) {

		List<JmReportGraduateDate> jmreportGraduateDate = jmreportService.getGraduateData(pageNo,pageSize,campusname, buildingname);
		JSONObject object = new JSONObject();
		object.put("data",jmreportGraduateDate);
		object.put("total",(int)Math.ceil(jmreportGraduateDate.size() / (double)pageSize));
		object.put("count",jmreportGraduateDate.size());
		return object;
	}



	*//**
	 * 获取学生院系分布
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-院系分布")
	@ApiOperation(value="积木报表api-院系分布", notes="积木报表api-院系分布")
	@GetMapping(value = "/queryFacultyData")
	public JSONObject  queryFacultyData(
			@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,
			@RequestParam(name = "pageSize",defaultValue = "20000") Integer pageSize,
			@RequestParam(value = "campusname",required = false)String campusName,
			@RequestParam(value = "yearname",required = false)String yearName,
			@RequestParam(value = "facultyname",required = false)String facultyName

	) {

		List<JmReportFacultyDate> jmreportFacultyDate = jmreportService.getFacultyData(pageNo,pageSize,campusName,yearName,facultyName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportFacultyDate);
		object.put("total",(int)Math.ceil(jmreportFacultyDate.size() / (double)pageSize));
		object.put("count",jmreportFacultyDate.size());
		return object;

	}

	*//*院系钻取1*//*
	@AutoLog(value = "积木报表api-院系楼宇分布")
	@ApiOperation(value="积木报表api-院系楼宇分布", notes="积木报表api-院系楼宇分布")
	@GetMapping(value = "/queryFacultyBuildingData")
	public JSONObject  queryFacultyBuildingData(
			@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,
			@RequestParam(name = "pageSize",defaultValue = "20000") Integer pageSize,
			@RequestParam(value = "facultyId",required = false)String facultyId,
			@RequestParam(value = "year",required = false)String year
	) {

		List<JmReportFacultyBuildingDate> jmreportFacultyDate = jmreportService.queryFacultyBuildingData(pageNo,pageSize,facultyId,year);
		JSONObject object = new JSONObject();
		object.put("data",jmreportFacultyDate);
		object.put("total",(int)Math.ceil(jmreportFacultyDate.size() / (double)pageSize));
		object.put("count",jmreportFacultyDate.size());
		return object;

	}



	*//**
	 * 获取楼宇房间住宿情况---图
	 *
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-房间住满情况")
	@ApiOperation(value="积木报表api-房间住满情况", notes="积木报表api-房间住满情况")
	@GetMapping(value = "/queryStuLiveChart")
	public JSONObject  queryStuLiveChart(
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName) {
		List<Map<String,String>> jmreportHotelDate = jmreportService.queryStuLiveChart(campusName, buildingName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		return object;
	}	*//**
	 * 获取楼宇房间住宿情况---图
	 *
	 *
	 * @return
	 *//*


	*//**
	 * 房间类型分布情况---图
	 *
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-房间类型分布情况（楼）")
	@ApiOperation(value="积木报表api-房间类型分布情况（楼）", notes="积木报表api-房间类型分布情况（楼）")
	@GetMapping(value = "/queryRoomTypeChart")
	public JSONObject  queryRoomTypeChart(
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName) {
		List<Map<String,String>> jmreportHotelDate = jmreportService.queryRoomTypeChart(campusName, buildingName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		return object;
	}	*//**
	 * 房间类型分布情况---图
	 *
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-房间类型分布情况（层）")
	@ApiOperation(value="积木报表api-房间类型分布情况（层）", notes="积木报表api-房间类型分布情况（层）")
	@GetMapping(value = "/queryRoomTypeLayerChart")
	public JSONObject  queryRoomTypeLayerChart(
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName) {
		List<Map<String,String>> jmreportHotelDate = jmreportService.queryRoomTypeLayerChart(campusName, buildingName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		return object;
	}

	*//**
	 * 学院分布---图
	 *
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-学院分布（楼）")
	@ApiOperation(value="积木报表api-学院分布（楼）", notes="积木报表api-学院分布（楼）")
	@GetMapping(value = "/queryCollegeChart")
	public JSONObject  queryCollegeChart(
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName) {
		List<Map<String,String>> jmreportHotelDate = jmreportService.queryCollegeChart(campusName, buildingName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		return object;
	}	*//**
	 * 房间类型分布情况---图
	 *
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-学院分布（层）")
	@ApiOperation(value="积木报表api-学院分布（层）", notes="积木报表api-学院分布（层）")
	@GetMapping(value = "/queryCollegeLayerChart")
	public JSONObject  queryCollegeLayerChart(
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName,
			@RequestParam(value = "unitName",required = false)String unitName,
			@RequestParam(value = "layerName",required = false)String layerName) {
		List<Map<String,String>> jmreportHotelDate = jmreportService.queryCollegeLayerChart(campusName, buildingName,unitName,layerName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		return object;
	}



	*//**
	 * 年级分布---图
	 *
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-年级分布（楼）")
	@ApiOperation(value="积木报表api-年级分布（楼）", notes="积木报表api-年级分布（楼）")
	@GetMapping(value = "/queryYearChart")
	public JSONObject  queryYearChart(
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName) {
		List<Map<String,String>> jmreportHotelDate = jmreportService.queryYearChart(campusName, buildingName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		return object;
	}	*//**
	 * 年级分布---图
	 *
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-年级分布（层）")
	@ApiOperation(value="积木报表api-年级分布（层）", notes="积木报表api-年级分布（层）")
	@GetMapping(value = "/queryYearLayerChart")
	public JSONObject  queryYearLayerChart(
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName,
			@RequestParam(value = "unitName",required = false)String unitName,
			@RequestParam(value = "layerName",required = false)String layerName) {
		List<Map<String,String>> jmreportHotelDate = jmreportService.queryYearLayerChart(campusName, buildingName,unitName,layerName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		return object;
	}


	*//**
	 * 学历分布---图
	 *
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-学历分布（楼）")
	@ApiOperation(value="积木报表api-学历分布（楼）", notes="积木报表api-学历分布（楼）")
	@GetMapping(value = "/queryNationChart")
	public JSONObject  queryNationChart(
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName) {
		List<Map<String,String>> jmreportHotelDate = jmreportService.queryNationChart(campusName, buildingName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		return object;
	}	*//**
	 * 学历分布---图
	 *
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-学历分布（层）")
	@ApiOperation(value="积木报表api-学历分布（层）", notes="积木报表api-学历分布（层）")
	@GetMapping(value = "/queryNationLayerChart")
	public JSONObject  queryNationLayerChart(
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName,
			@RequestParam(value = "unitName",required = false)String unitName,
			@RequestParam(value = "layerName",required = false)String layerName) {
		List<Map<String,String>> jmreportHotelDate = jmreportService.queryNationLayerChart(campusName, buildingName,unitName,layerName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportHotelDate);
		return object;
	}

	*//**
	 * 获取空房间数据
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-空房间数据")
	@ApiOperation(value="积木报表api-空房间数据", notes="积木报表api-空房间数据")
	@GetMapping(value = "/queryNullRoomData")
	public JSONObject  queryNullRoomData(
			@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,
			@RequestParam(name = "pageSize",defaultValue = "20000") Integer pageSize,
			@RequestParam(value = "campusName",required = false)String campusName,
			@RequestParam(value = "buildingName",required = false)String buildingName

	) {

		List<JmReportRoomDate> jmreportGraduateDate = jmreportService.getNullRoomData(pageNo,pageSize,campusName, buildingName);
		JSONObject object = new JSONObject();
		object.put("data",jmreportGraduateDate);
		object.put("total",(int)Math.ceil(jmreportGraduateDate.size() / (double)pageSize));
		object.put("count",jmreportGraduateDate.size());
		return object;
	}

	*//**
	 * 获取院系房间数据
	 *
	 * @return
	 *//*
	@AutoLog(value = "积木报表api-获取院系房间数据")
	@ApiOperation(value="积木报表api-获取院系房间数据", notes="积木报表api-获取院系房间数据")
	@GetMapping(value = "/queryCollegeRooms")
	public JSONObject  queryCollegeRooms(
			@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,
			@RequestParam(name = "pageSize",defaultValue = "20000") Integer pageSize

	) {

		List<Map<String,String>> jmreportGraduateDate = jmreportService.queryCollegeRooms();
		JSONObject object = new JSONObject();
		object.put("data",jmreportGraduateDate);
		object.put("total",(int)Math.ceil(jmreportGraduateDate.size() / (double)pageSize));
		object.put("count",jmreportGraduateDate.size());
		return object;
	}*/
}
